package day23;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.RandomAccessFile;

public class ReadPasswd {
	public static void main(String[] args)throws Exception {
		File f = new File("pointer");
		long pointer = 0;
		if(f.exists()){
			DataInputStream dis = new DataInputStream(new FileInputStream(f));
			pointer = dis.readLong();
			dis.close();
		}
		RandomAccessFile raf = new RandomAccessFile("passwd", "r");
		raf.seek(pointer);
		String str = null;
		for(int i=0; i<10; i++){
			str = raf.readLine();
			if(str==null){
				System.exit(0);
			}
			System.out.println(str);
		}
		pointer = raf.getFilePointer();
		DataOutputStream dos = new DataOutputStream(new FileOutputStream("pointer"));
		dos.writeLong(pointer);
		dos.close();
		raf.close();
	}
}
